package models;

import java.util.*;
import javax.persistence.*;
 
import play.data.binding.*;
import play.data.validation.*;
import play.db.jpa.*;
 
@Entity
public class User extends Model {
	
	  @Required
    public String username;
	  
	  @Required
    public String password;
	      
	  @Email
	  @Required
    public String email;
    public boolean isAdmin;
    
    public User(String username, String password, String email) {
        this.email = email;
        this.password = password;
        this.username = username;
        this.isAdmin = false;
    }
    
    public static User connect(String username,String password){
    	//password = Codec.hexMD5(password);
    	return User.find("byUsernameAndPassword", username,password).first();
    }
    	public static User findUser(String username){
        	//password = Codec.hexMD5(password);
        	return User.find("byUsername", username).first();
    }
 
}


